import 'package:flutter/material.dart';
import 'package:robotcontrol/entity/Data.dart';
import 'package:robotcontrol/page/page2.dart';

class Page1 extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text("第一个页面"),
      ),
      body: Column(
        children: [
          RaisedButton(
            onPressed: () async{
              // Navigator.push(context, MaterialPageRoute(builder: (_){return Page2();}))
              // .then((value){
              //   debugPrint(value.toString());
              // })
           // var result =   await Navigator.push(context, MaterialPageRoute(builder: (_){return Page2();}));
           // debugPrint(result.toString()+"xcsd");
           //    var result = await Navigator.pushNamed(context,"/page2");
              //跳转动画
              var result =   await Navigator.push(context,
                  PageRouteBuilder(
                      // transitionDuration: Duration(microseconds: 500),转场动画时间
                      pageBuilder: (
                  BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation
              ){
                // return Page2();

                return FadeTransition(//渐变动画
                  opacity: animation,child:SlideTransition(//平移动画
                    position: Tween(begin: Offset(1.0,0.0),end:Offset(0.0,0.0) ).animate(animation),
                    child: Page2()),);
              }));
              result = result+result;
             var sub = ( result as Data).su((x, inty)  {
               var sub = x + inty;
               return sub;
              });
             debugPrint(result.toString()+"sss ${sub}");
              ;},

            child: Text("跳转到第二个页面"),)
        ],
      ),
    );
  }

}